package forum.command;

import forum.entities.Category;
import forum.entities.User;
import forum.services.UserService;

public class CreateTopicCommand implements Command {

    private String topicName;
    private String topicStarterMessage;
    private Category currentCategory;
    private User user;

    private UserService userService = new UserService();

    @Override
    public void execute() {
        userService.createTopic(user, currentCategory, topicName,topicStarterMessage);
    }

    @Override
    public void setParameters(String... args) {
        if (args.length != 2) {
            throw new IllegalArgumentException ("Incorrect number of arguments");
        }
        topicName = args[0];
        topicStarterMessage = args[1];
    }

    @Override
    public void setContext(CommandContext context) {
        user = context.getUser();
        currentCategory = context.getCategory();
    }

    @Override
    public void updateContext(CommandContext context) {

    }

    @Override
    public String help() {
        return "Type new_topic | %topicName% | %TS message%";
    }
}
